package com.mall.commons.exceotion;

import com.mall.commons.exceotion.exception.BusinessException;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 统一异常处理器
 */
@ControllerAdvice
public class ExceptionAdvice {

/*    @ExceptionHandler(BusinessException.class)
    public ResponseEntity businessException(BusinessException be){
        be.printStackTrace();
        ErrorResult errorResult = be.getErrorResult();
        //设置状态码500,和返回的错误信息
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResult);
    }

    @ExceptionHandler({Exception.class})
    public ResponseEntity exception(Exception ex){
        ex.printStackTrace();
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ErrorResult.error());
    }*/



}
